//
//  LYCompanyCheckMeCell.m
//  SelectCity
//
//  Created by liuyan on 2019/3/20.
//  Copyright © 2019年 liuyan. All rights reserved.
//

#import "LYCompanyCheckMeCell.h"

@interface LYCompanyCheckMeCell()

@property (nonatomic, strong) UIImageView *iconImage;
//标题
@property (nonatomic, strong) UILabel *titleLabel;
//时间
@property (nonatomic, strong) UILabel *timeLabel;
//期望工资
@property (nonatomic, strong) UILabel *wageLabel;
//意向职位
@property (nonatomic, strong) UILabel *positionLabel;

@end

@implementation LYCompanyCheckMeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubViews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - InitSubViews
- (void)initSubViews{
    UIView *backview = [[UIView alloc] initWithFrame:self.bounds];
    backview.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:backview];
    
    self.iconImage = [UIToolsControl initImageViewWithFrame:CGRectMake(15, 15, 50, 50) imageName:@"header_bg"];
    self.iconImage.contentMode = UIViewContentModeScaleAspectFill;
    self.iconImage.layer.cornerRadius = self.iconImage.height/2;
    self.imageView.layer.masksToBounds = YES;
    [backview addSubview:self.iconImage];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right +8, 15,140, 20)];
    self.titleLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.titleLabel.font = FontBold(Font_15);
    self.titleLabel.adjustsFontSizeToFitWidth = YES;
    [backview addSubview:self.titleLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.right, 15, WIDTH - self.titleLabel.right -10, 20)];
    self.timeLabel.textColor = THEMECOLOR_OF_TEXT_9a9a9a;
    self.timeLabel.font = Font(Font_11);
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.adjustsFontSizeToFitWidth = YES;
    [backview addSubview:self.timeLabel];
    
    self.wageLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right +8, self.titleLabel.bottom+10,WIDTH - self.iconImage.right - 18, 20)];
    self.wageLabel.textColor = THEMECOLOR_OF_TEXT_666666;
    self.wageLabel.font = Font(Font_13);
    [backview addSubview:self.wageLabel];
    
    self.positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right +8, self.wageLabel.bottom+10,WIDTH - self.iconImage.right - 18, 20)];
    self.positionLabel.textColor = THEMECOLOR_OF_TEXT_666666;
    self.positionLabel.font = Font(Font_13);
    [backview addSubview:self.positionLabel];
    
    UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(self.positionLabel)+15*Scale, WIDTH, 10*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [backview addSubview:lineView];
}

#pragma mark -- Data
- (void)setModel:(LYCompanyCheckMeModel *)model {
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:model.name];
    NSAttributedString *strq1 = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@ | %li岁 | %@", model.sex_cn, [model.age integerValue], model.education_cn] attributes:@{NSForegroundColorAttributeName:THEMECOLOR_OF_TEXT_666666, NSFontAttributeName:Font(Font_13)}];
    [str appendAttributedString:strq1];
    self.titleLabel.attributedText = str;
    
    NSString *time = model.view_time;
    self.timeLabel.text = [NSString stringWithFormat:@"%@",time];
    
    if ([model.experience_cn isEqualToString:@"0"]) {
        //应届生
        NSMutableAttributedString *experiencestr = [[NSMutableAttributedString alloc] initWithString:@"应届生 期望薪资："];
        NSAttributedString *strq = [[NSAttributedString alloc] initWithString:model.wage_cn attributes:@{NSForegroundColorAttributeName:THEMECOLOR_OF_RED, NSFontAttributeName:Font(Font_13)}];
        [experiencestr appendAttributedString:strq];
        self.wageLabel.attributedText = experiencestr;
    } else {
        NSMutableAttributedString *experiencestr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"工作经验 %@ 期望薪资：",model.experience_cn]];
        NSAttributedString *strq = [[NSAttributedString alloc] initWithString:model.wage_cn attributes:@{NSForegroundColorAttributeName:THEMECOLOR_OF_RED, NSFontAttributeName:Font(Font_13)}];
        [experiencestr appendAttributedString:strq];
        self.wageLabel.attributedText = experiencestr;
    }
    
    self.positionLabel.text = [NSString stringWithFormat:@"意向职位 %@", model.intention_jobs];
}

@end
